﻿#include "ParamConfig.h"

//静态变量类外初始化
ParamConfig *ParamConfig::inst = nullptr;
QSettings   *ParamConfig::devSetting = nullptr;

ParamConfig::ParamConfig(QObject *parent) : QObject(parent)
{

}

ParamConfig::~ParamConfig()
{
    if(inst != nullptr)
    {
        delete inst;
        inst = nullptr;
    }
    if(devSetting != nullptr)
    {
        delete devSetting;
        devSetting = nullptr;
    }

}

void ParamConfig::Init()
{
    devSetting = new QSettings("DeviceInfo.ini",QSettings::NativeFormat);

    //   设备信息初始化
    devSetting->beginGroup("DeviceInformation");

    if(!devSetting->contains("DeviceNo"))      devSetting->setValue("DeviceNo", 1);                  //   设备编号
    if(!devSetting->contains("ServerIP"))
    {
    }
    if(!devSetting->contains("ServerPort"))    devSetting->setValue("ServerPort", "8080");           //   服务器端口号
    if(!devSetting->contains("DeviceIP"))      devSetting->setValue("DeviceUrl","200.200.200.191");  //   工控屏URL
    if(!devSetting->contains("DevicePort"))    devSetting->setValue("DevicePort", "22");             //   工控屏端口号
    if(!devSetting->contains("DeviceMask"))    devSetting->setValue("DeviceMask","255.255.255.0");   //   工控屏URL
    if(!devSetting->contains("DeviceGateway")) devSetting->setValue("DeviceUrl","200.200.200.1");    //   工控屏网关
    if(!devSetting->contains("LayerCount"))    devSetting->setValue("LayerCount", 4);               //   柜子总层数
    if(!devSetting->contains("SubCount"))     devSetting->setValue("SubCount", 1);                //   柜子总节数

//    if(!devSetting->contains("HumidityThreshold"))devSetting->setValue("HumidityThreshold", "50");   //   设置显示湿度上限
//    if(!devSetting->contains("SmokeThreshold"))devSetting->setValue("SmokeThreshold", "50");         //   设置烟雾上限
//    if(!devSetting->contains("TemperatureThreshold"))devSetting->setValue("TemperatureThreshold", "50");   //温度上限
    if(!devSetting->contains("StockInfoServerPort"))devSetting->setValue("StockInfoServerPort", "8081");   //存储信息柜存量等服务器获取端口

    if(!devSetting->contains("SystemVersion"))devSetting->setValue("SystemVersion", "v1.0");   //系统版本
    if(!devSetting->contains("DeviceModel"))devSetting->setValue("DeviceModel", "WRC");   //设备型号
    if(!devSetting->contains("CabinetName"))devSetting->setValue("CabinetName", "人事柜");   //柜名称

    devSetting->endGroup();

}

